package com.epfly.promo.activity.dao;

import com.epfly.promo.activity.entity.ActivityRuleEntity;
import org.apache.ibatis.annotations.*;
import tk.mybatis.mapper.additional.insert.InsertListMapper;
import tk.mybatis.mapper.common.BaseMapper;

import java.util.List;
@Mapper
public interface ActivityRuleMapper extends BaseMapper<ActivityRuleEntity>, InsertListMapper<ActivityRuleEntity> {



    @Delete(value = "delete from tbl_activity_rule where activity_id = #{activityId} and del_flag = 0")
    int deleteByActivityId(@Param(value = "activityId") Long activityId);


    @ResultMap(value = "activityRuleMapperBaseResultMap")
    @Select(value = "select id, dinner_type, rule_content from tbl_activity_rule where activity_id = #{activityId} and del_flag = 0")
    List<ActivityRuleEntity> findByActivityId(@Param(value = "activityId") Long activityId);

    ActivityRuleEntity existsByActivityIdAndDinnerTypeList(@Param(value = "activityId") Long activityId, @Param(value = "dinnerTypeList") List<Byte> dinnerTypeList);


    ActivityRuleEntity findByActivityIdAndDinnerTypeList(@Param(value = "activityId") Long activityId, @Param(value = "dinnerTypeList") List<Byte> dinnerTypeList);
}
